package com.qfedu.openplateform.szapi.controller;

import com.qfedu.openplateform.szapi.config.RestTemplateConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;

@RestController
public class PortsController {


    @Autowired
    private RestTemplate restTemplate;

    /**
     * 深圳所有厕所
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/getWcPort")
    public String WcPort(int page,int rows){
        HashMap<String,Object> hashMap = new HashMap<>();
        hashMap.put("page",page);
        hashMap.put("rows",rows);
        hashMap.put("appKey","27116e4a5aac4f13af2c0e2141b1ddae");
        String templateForObject = restTemplate.getForObject("https://opendata.sz.gov.cn/api/339779363/1/service.xhtml?" + "appKey={appKey}&page={page}&rows={rows}", String.class, hashMap);
        return templateForObject;

    }

    /**
     * 深圳十天天气
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/getWeatherPort")
    public String WeatherPort(int page,int rows){
        HashMap<String,Object> hashMap = new HashMap<>();
        hashMap.put("page",page);
        hashMap.put("rows",rows);
        hashMap.put("appKey","27116e4a5aac4f13af2c0e2141b1ddae");
        String templateForObject = restTemplate.getForObject("https://opendata.sz.gov.cn/api/1964883385/1/service.xhtml?" + "appKey={appKey}&page={page}&rows={rows}", String.class, hashMap);
        return templateForObject;

    }


    /**
     * 深圳每日天气
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/getOneWeatherPort")
    public String OneWeatherPort(int page,int rows){
        HashMap<String,Object> hashMap = new HashMap<>();
        hashMap.put("page",page);
        hashMap.put("rows",rows);
        hashMap.put("appKey","27116e4a5aac4f13af2c0e2141b1ddae");
        String templateForObject = restTemplate.getForObject("https://opendata.sz.gov.cn/api/1180127746/1/service.xhtml?" + "appKey={appKey}&page={page}&rows={rows}", String.class, hashMap);
        return templateForObject;

    }

    /**
     * 新冠肺炎
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/getCOVID-19Port")
    public String COVIDPort(int page,int rows){
        HashMap<String,Object> hashMap = new HashMap<>();
        hashMap.put("page",page);
        hashMap.put("rows",rows);
        hashMap.put("appKey","27116e4a5aac4f13af2c0e2141b1ddae");
        String templateForObject = restTemplate.getForObject("https://opendata.sz.gov.cn/api/29200_01503673/1/service.xhtml?" + "appKey={appKey}&page={page}&rows={rows}", String.class, hashMap);
        return templateForObject;

    }


    /**
     * 深圳街道
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/getStreetPort")
    public String StreetPort(int page,int rows){
        HashMap<String,Object> hashMap = new HashMap<>();
        hashMap.put("page",page);
        hashMap.put("rows",rows);
        hashMap.put("appKey","27116e4a5aac4f13af2c0e2141b1ddae");
        String templateForObject = restTemplate.getForObject("https://opendata.sz.gov.cn/api/29200_00403589/1/service.xhtml?" + "appKey={appKey}&page={page}&rows={rows}", String.class, hashMap);
        return templateForObject;

    }


    /**
     * 深圳公园
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/getGardenPort")
    public String GardenPort(int page,int rows){
        HashMap<String,Object> hashMap = new HashMap<>();
        hashMap.put("page",page);
        hashMap.put("rows",rows);
        hashMap.put("appKey","27116e4a5aac4f13af2c0e2141b1ddae");
        String templateForObject = restTemplate.getForObject("https://opendata.sz.gov.cn/api/788742698/1/service.xhtml?" + "appKey={appKey}&page={page}&rows={rows}", String.class, hashMap);
        return templateForObject;

    }




}
